package com.quan.site.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quan.commons.annotation.OperationLog;
import com.quan.commons.core.MyBaseController;
import com.quan.commons.utils.PageUtils;
import com.quan.commons.vo.R;
import com.quan.site.commons.vo.SiteEnterpriseVo;
import com.quan.site.entity.SiteEnterprise;
import com.quan.site.service.SiteEnterpriseService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/**
 * 官网-企业文化
 *
 * @author yhaoquan
 * @email yhaoquan@163.com
 * @date 2023-08-19 17:31:59
 */
@Slf4j
@Api(tags = "官网-企业文化")
@RestController
@RequestMapping("/api/siteenterprise")
public class ApiEnterpriseController extends MyBaseController {

    @Autowired
    private SiteEnterpriseService service;


    /**
     * 多条件查询信息详情
     *
     * @param vo
     * @return
     */
    @OperationLog(module = "官网-企业文化", title = "查询详情")
    @GetMapping("/info")
    public R info(SiteEnterpriseVo vo) {
        QueryWrapper<SiteEnterprise> queryWrapper = new QueryWrapper<SiteEnterprise>(vo);
        SiteEnterprise siteEnterprise = this.service.getOne(queryWrapper);
        return R.ok().data(siteEnterprise);
    }

    /**
     * 根据ID查询信息详情
     *
     * @param {id}
     * @return
     */
    @OperationLog(module = "官网-企业文化", title = "查询详情")
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id) {
        SiteEnterprise siteEnterprise = this.service.getById(id);
        return R.ok().data(siteEnterprise);
    }

    /**
     * 列表查询
     *
     * @param vo
     * @return
     */
    @OperationLog(module = "官网-企业文化", title = "查询列表")
    @GetMapping(value = "list")
    public Object list(SiteEnterpriseVo vo) {
        List<SiteEnterpriseVo> list = this.service.queryList(new PageUtils(request), vo);
        return R.ok().data(list);
    }

    /**
     * 根据类别（cate）分组查询
     *
     * @param vo
     * @return
     */
    @OperationLog(module = "官网-企业文化", title = "查询列表")
    @GetMapping(value = "listMap")
    public Object listMap(SiteEnterpriseVo vo) {
        final Map<Integer, List<SiteEnterpriseVo>> listMap = this.service.listMapGroupMap(new PageUtils(request), vo);
        return R.ok().data(listMap);
    }


    /**
     * 分页查询
     *
     * @param vo
     * @return
     */
    @OperationLog(module = "官网-企业文化", title = "查询列表")
    @GetMapping(value = "page")
    public R queryPage(SiteEnterpriseVo vo) {
        PageUtils page = this.service.queryPage(new PageUtils(request), vo);
        return R.ok().data(page);
    }

}
